# -*- coding: utf-8 -*-

class EventHandler:

    handlers = {}

    @staticmethod
    def subscripe(channel, handler):
        if channel not in EventHandler.handlers:
            EventHandler.handlers[channel] = []
        EventHandler.handlers[channel].append(handler)

    @staticmethod
    def post(event):
        if isinstance(event, Event) and event.type in EventHandler.handlers:
            for handler in EventHandler.handlers[event.type]:
                handler.handle(event)

class Event:

    def __init__(self, type=None):
        self.type = type